﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;

namespace S7.Windows.Reservations
{
    /// <summary>
    /// Interaction logic for EditReservations.xaml
    /// </summary>
    public partial class EditReservations : Window
    {
        public EditReservations()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Thread thrSearch = new Thread(new ThreadStart(() =>
            {
                try
                {
                    List<Booking> lstBookings = Booking.Pending();
                    dgReservations.Dispatcher.Invoke(new ThreadStart(() =>
                    {
                        try
                        {
                            dgReservations.ItemsSource = lstBookings;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                        }

                    }), null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                }

            }));
            thrSearch.IsBackground = true;
            thrSearch.Start();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var w = new AddAReservation();
            w.ShowDialog();
        }

        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
